package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.domain.ncc.NccBasicUnit;
import com.bzkj.basicinfo.service.ncc.NccBasicUnitService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.domain.R;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @Author wangzhichao
 * @ClassName NccBasicUnitController
 * @Date 2024/12/10 11:17:19
 * @description ncc物料单位表
 */
@Api(tags = "商品单位")
@RestController
@RequestMapping("/ncc/basic/unit")
public class NccBasicUnitController extends BaseController {
    @Autowired
    private NccBasicUnitService nccBasicUnitService;

    /**
     * 查询物料信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 11:26:19
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBasicUnitData")
    public TableDataInfo findNccBasicUnitData(NccBasicUnit entity) {
        startPage();
        return getDataTable(nccBasicUnitService.findNccBasicUnitData(entity));
    }
    /**
     * 查询物料信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 11:26:19
     */
    @ApiOperation("查询接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findAllNccBasicUnitData")
    public AjaxResult findAllNccBasicUnitData(NccBasicUnit entity) {
        return AjaxResult.success(nccBasicUnitService.findNccBasicUnitData(entity));
    }

    /**
     * 修改物料信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 15:14:59
     * @Param entity
     */
    @ApiOperation("修改接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:edit')")
    @PutMapping("nccBasicUnitUpdate")
    @LogC(title = "ncc商品单位", businessType = BusinessType.UPDATE,
            tableNames = "ncc_basic_unit", pkFieldNames = "id", content = "' 物料名称：'+#entity.name")
    public AjaxResult nccBasicUnitUpdate(@RequestBody NccBasicUnit entity) {
        return nccBasicUnitService.nccBasicUnitUpdate(entity);
    }

    /**
     * 新增物料信息
     *
     * @Author wangzhichao
     * @Date 2024/12/10 16:49:25
     * @Param entity
     */
    @ApiOperation("新增接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:add')")
    @PostMapping("nccBasicUnitSave")
    @LogC(title = "ncc商品单位", businessType = BusinessType.INSERT,
            tableNames = "ncc_basic_unit", pkFieldNames = "id", content = "' 物料名称：'+#entity.name")
    public AjaxResult nccBasicUnitSave(@RequestBody NccBasicUnit entity) {
        return nccBasicUnitService.nccBasicUnitSave(entity);
    }

    /**
     * 获取所有物料信息
     *
     * @Author wangzhichao
     * @Date 2024/12/17 20:01:27
     */
    @ApiOperation("查询单位下拉接口")
    @PreAuthorize("@ss.hasPermi('basic:nccBasic:query')")
    @GetMapping("findNccBasicUnitAll")
    public R findNccBasicUnitAll() {
        return nccBasicUnitService.findNccBasicUnitAll();
    }

    @ApiOperation("删除接口")
    @DeleteMapping("/delete")
    public AjaxResult deleteById(String id){
        return nccBasicUnitService.deleteNccBasicUnit(id);
    }

    /**
     * 定时任务
     *
     * @return
     */
    @GetMapping("jobMethod")
    public R jobMethod() {
        return nccBasicUnitService.jobMethodExecute(false);
    }


}
